ans = 0
N = 300000

for i in xrange(11, N):
    a = [int(x) ** 5 for x in list(str(i))]
    if sum(a) == i:
        ans += i

print ans

